package pl.mikei.deliverydroid;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;


public class IconPreferenceScreen extends Preference {
    private final Drawable mIcon;
//    private static String mType;

    public IconPreferenceScreen(Context context, AttributeSet attrs, int iconRes) {
        this(context, attrs, 0, iconRes);
    }
    public IconPreferenceScreen(Context context, AttributeSet attrs,
            int defStyle, int iconRes) {
        super(context, attrs, defStyle);
        setLayoutResource(R.layout.preference_icon);
        mIcon = context.getResources().getDrawable(iconRes);
    }
    public IconPreferenceScreen(Context context, int iconRes) {
        this(context, null, iconRes);
    }
    @Override
    public void onBindView(View view) {
        super.onBindView(view);
        ImageView imageView = (ImageView) view.findViewById(R.id.icon);
        if (imageView != null && mIcon != null) {
            imageView.setImageDrawable(mIcon);
        }
    }
}
